package com.ehe.common.core.definition;

/**
 * redis 键定义
 * @author jerry
 */
public final class RedisKeyDefinition {

    private RedisKeyDefinition() {
    }

    /** 项目前缀 **/
    public final static String PROJECT_PREFIX = "ehe:";

    /** elder **/
    public final static String ELDER_PREFIX = "elder:";

    /** 业务前缀 **/
    public final static String SYS_PREFIX = "appraise:";

    /** 用户token */
    public static final String TOKEN = "identity:token:principalId";

    /** 短信验证码 */
    public static final String SHORT_MESSAGE_VERIFICATION_CODE = "core:shortMessage:verificationCode:mobile";

    /** 用户TO */
    public static final String PRINCIPAL_TO = "identity:principal:id";

    /** 组织信息 */
    public static final String ORGANIZATION_ID = "identity:organization:id";

    /** 资源信息 */
    public static final String RESOURCE_ID = "identity:resource:id";

    /** license 序列 */
    public static final String LICENSE_SEQUENCE = "license:sequence:";

    /** 行政区域缓存 */
    public static final String DISTINCT = "elder:distinct:list:all";

    /** 行政区域缓存-pid */
    public static final String DISTINCT_PID = "elder:distinct:pid:";

    /** 长者中心动态搜索缓存 */
    public static final String ELDERDYNAMICA = "elder:dynamica:search:record:";

    /** 新闻点击缓存 */
    public static final String ELDERNEWS = "elder:news:record:";

    /** 字典数据缓存 */
    public static final String ALLMAP = "setting:all:map";

    /** 首页横幅数据缓存 */
    public static final String BANNERINFO = "elder:banner:list:";

    /** 志愿者中心 */
    public static final String TOTAL_TOP = "elder:volunteer:top";

    /** 老人信息数据缓存 */
    public static final String ELDERINFO = "elder:elderInfo:list:";

    /** 烟感 */
    public static final String SMOKE_DETECTOR = "elder:smoke:detector";

    /** 推送平台消息 */
    public static final String PUSH_PLATFORM_MSG = "elder:push:message";

    /**
     * 订单支付状态 key = AUTOSELL:ORDER:PAY:STATUS:订单ID，value = PAYING:待付款，PAID : 已付款
     */
    public static final String ORDER_PAY_STATUS_PERF = "ORDER:PAY:STATUS:";

    /**
     * 追加系统前缀
     * @param suffix 字符串
     * @return
     */
    public static String appendSysPrefix(String suffix){
        StringBuilder builder = new StringBuilder();
        builder.append(PROJECT_PREFIX);
        builder.append(ELDER_PREFIX);
        builder.append(SYS_PREFIX);
        builder.append(suffix);
        return builder.toString();
    }


    /**
     * 获取列表key
     */
    public static String getIpUriKey(String ip, String uri) {
        return appendSysPrefix("ip="+ip+"#uri="+uri);
    }

    /**
     * 获取列表key
     */
    public static String getIpUriKey(String ip, String uri,String principalId) {
        return appendSysPrefix("ip="+ip+"#uri="+uri+"#principalId="+principalId);
    }

}
